import { Tasks } from '@/global/creep-task';
import { runIntervally } from '@/utils/functions/inInterval';
import { Logger } from '@/utils/logger';
import { BaseColonyModule } from '../moduleBase';

export class UpgradeModule extends BaseColonyModule {

    handle() {
        const spawn = this.colony.capital.getSpawns()[0];
        const controller = this.colony.capital.getController();
        this.runCreeps(CreepRole.upgrader, upgrader => {
            if (this.colony.level <= 2) {
                upgrader.addTask(Tasks.withdraw(spawn, RESOURCE_ENERGY));
                upgrader.addTask(Tasks.upgrade(controller));
            }
            else {
                // todo: refactor these
            }
        });
    }

}